<?php $user = $this->user?>
<?php $myCartObj = new Cart(); $myCartInfo = $myCartObj->getMyCart();$siteConfig=new Config("site_config");?>
<?php $siteConfigObj = new Config("site_config");$site_config   = $siteConfigObj->getInfo();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $siteConfig->name;?></title>
<link type="image/x-icon" href="favicon.ico" rel="icon">
<link type="image/x-icon" href="favicon.ico" rel="bookmark">
<link rel="stylesheet" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/css/index.css";?>" />
<link rel="stylesheet" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/css/jquery.jqzoom.css";?>" />
<script charset="UTF-8" src="/runtime/systemjs/jquery-1.4.4.min.js"></script>
<script charset="UTF-8" src="/runtime/systemjs/form.js"></script>
<link rel="stylesheet" type="text/css" href="/runtime/systemjs/autovalidate/style.css"/><script charset="UTF-8" src="/runtime/systemjs/autovalidate/validate.js"></script>
<script charset="UTF-8" src="/runtime/systemjs/artdialog/artDialog.min.js"></script>
<script type='text/javascript' src="<?php echo IUrl::creatUrl("")."views/".$this->theme."/javascript/common.js";?>"></script>
<script type='text/javascript' src="<?php echo IUrl::creatUrl("/javascript/adloader/");?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/";?>jquery.bxSlider/bx_styles/bx_styles.css" />
</head>
<body class="index">
<div class="container">
	<div class="header">
		<h1 class="logo"><a title="<?php echo $siteConfig->name;?>" style="background:url(<?php echo IUrl::creatUrl("")."image/logo.gif";?>);" href="<?php echo IUrl::creatUrl("");?>"><?php echo $siteConfig->name;?></a></h1>
		<ul class="shortcut">
			<li class="first"><a href="<?php echo IUrl::creatUrl("/ucenter/index");?>">我的账户</a></li><li><a href="<?php echo IUrl::creatUrl("/ucenter/order");?>">我的订单</a></li><!-- <li class='last'><a href="<?php echo IUrl::creatUrl("/site/help_list");?>">使用帮助</a></li> -->
		</ul>
		<p class="loginfo">
			<?php if((isset($user['user_id']) && $user['user_id']!='')){?><?php echo isset($user['username'])?$user['username']:"";?>您好，欢迎您来到<?php echo $siteConfig->name;?>购物！[<a href="<?php echo IUrl::creatUrl("/simple/logout");?>" class="reg">安全退出</a>]<?php }else{?>[<a href="<?php echo IUrl::creatUrl("/simple/login");?>">登录</a>
			<?php $callback = IReq::get('callback')?>
			<?php if($callback==""){?>
			<a class="reg" href="<?php echo IUrl::creatUrl("/simple/reg");?>">免费注册</a>
			<?php }else{?>
			<?php $callback=urlencode($callback);?>
			<a class="reg" href="<?php echo IUrl::creatUrl("/simple/reg/?callback=$callback");?>">免费注册</a>
			<?php }?>
			]
			<?php }?>
		</p>
	</div>
	<div class="navbar">
		<ul>
			<li><a href="<?php echo IUrl::creatUrl("");?>">首页</a></li>
			<?php $i=0;?>
			<?php $query = new IQuery("guide");$items = $query->find(); foreach($items as $key => $item){?>
			<?php $i++;$item['link']=IUrl::creatUrl($item['link']);?>
			<li <?php if($i==count($items)){?>style="background:none;"<?php }?>><a href="<?php echo isset($item['link'])?$item['link']:"";?>"><?php echo isset($item['name'])?$item['name']:"";?><span> </span></a></li>
			<?php }?>
		</ul>

		<div class="mycart">
			<dl>
				<dt><a href="<?php echo IUrl::creatUrl("/simple/cart");?>">购物车<b name="mycart_count"><?php echo isset($myCartInfo['count'])?$myCartInfo['count']:"";?></b>件</a></dt>
				<dd><a href="<?php echo IUrl::creatUrl("/simple/cart");?>">去结算</a></dd>
			</dl>

			<!--购物车浮动div 开始-->
			<div class="shopping" id='div_mycart' style='display:none;'>
			</div>
			<!--购物车浮动div 结束-->

		</div>
	</div>

	<div class="searchbar">
		<div class="allsort">
			<a href="javascript:void(0);">全部商品分类</a>

			<!--总的商品分类-开始-->
			<ul class="sortlist" id='div_allsort' style='display:none'>
				<?php $this->goodsCategory = block::goods_category();?>
				<?php foreach($this->goodsCategory as $key => $first){?>
					<li>
						<h2><a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$first[id]");?>"><?php echo isset($first['name'])?$first['name']:"";?></a></h2>

						<!--商品分类 浮动div 开始-->
						<div class="sublist" style='display:none'>

							<div class="items">
								<strong>选择分类</strong>
								<?php if(isset($first['second'])){?>
								<?php foreach($first['second'] as $key => $second){?>
								<dl class="category selected">
									<dt>
										<a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$second[id]");?>"><?php echo isset($second['name'])?$second['name']:"";?></a>
									</dt>

									<dd>
										<?php if(isset($second['more'])){?>
										<?php foreach($second['more'] as $key => $third){?>
										<a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$third[id]");?>"><?php echo isset($third['name'])?$third['name']:"";?></a>|
										<?php }?>
										<?php }?>
									</dd>
								</dl>
								<?php }?>
								<?php }?>

							</div>

						</div>
						<!--商品分类 浮动div 结束-->

					</li>
				<?php }?>

			</ul>
			<!--总的商品分类-结束-->

		</div>

		<div class="searchbox">
			<form method='get'>
				<input type='hidden' name='controller' value='site' />
				<input type='hidden' name='action' value='search_list' />
				<?php $word = IReq::get('word');?>
				<input class="text" type="text" name='word' id="word" autocomplete="off" value="<?php echo $word ? $word : '输入关键字...';?>" />
				<input class="btn" type="submit" value="商品搜索" onclick="checkInput('word','输入关键字...');" />
			</form>

			<!--自动完成div 开始-->
			<ul class="auto_list" style='display:none'></ul>
			<!--自动完成div 开始-->

		</div>
		<div class="hotwords">热门搜索：
			<?php $query = new IQuery("keyword");$query->where = "hot = 1";$query->limit = "5";$query->order = "`order` asc";$items = $query->find(); foreach($items as $key => $item){?>
			<?php $tmpWord = urlencode($item['word']);?>
			<a href="<?php echo IUrl::creatUrl("/site/search_list/word/$tmpWord");?>"><?php echo isset($item['word'])?$item['word']:"";?></a>
			<?php }?>
		</div>
	</div>
	<div class="m_10" id="adHere_1"></div>
	<script language="javascript">
	(new adLoader()).load(1,'adHere_1');
	</script>

	<?php $comment_total=$this->data['comment_total'];?>
<?php $average_point=$this->data['average_point'];$average_point_width=($average_point/5)*70?>
<?php $id=intval(IReq::get('id'));?>

	<?php $query = new IQuery("goods");$query->where = "id = $id";$query->limit = "1";$items = $query->find(); foreach($items as $key => $item){?>
	<div class="position"> <span>您当前的位置：</span> <a href="<?php echo IUrl::creatUrl("");?>"> 首页</a> » <a href="<?php echo IUrl::creatUrl("/site/products/id/$id");?>"><?php echo isset($item['name'])?$item['name']:"";?></a> </div>
	<div class="wrapper clearfix">
		<div class="sidebar f_l">
			<div class="box_2 m_10">
				<div class="title">商品信息</div>
				<div class="content">
					<ul class="prolist clearfix">
						<li>
							<a href="<?php echo IUrl::creatUrl("/site/products/id/$id");?>"><img src="<?php echo IUrl::creatUrl("")."";?><?php echo isset($item['small_img'])?$item['small_img']:"";?>" title="<?php echo isset($item['name'])?$item['name']:"";?>" alt="<?php echo isset($item['name'])?$item['name']:"";?>" height="212" width="167"></a>
							<p class="pro_title">商品名称：<a class="blue" href="<?php echo IUrl::creatUrl("/site/products/id/$id");?>"><?php echo isset($item['name'])?$item['name']:"";?></a></p>
							<p>优惠价：<b><?php echo isset($item['sell_price'])?$item['sell_price']:"";?></b></p>
							<p>评价得分：<span class="grade"><i style="width:<?php echo isset($average_point_width)?$average_point_width:"";?>px"></i></span>(<?php echo isset($average_point)?$average_point:"";?>分)</p>
							<p>评论数：<?php echo isset($comment_total)?$comment_total:"";?>条</p>
						</li>
						<input type="submit" onclick="joinCart_list(<?php echo isset($id)?$id:"";?>);" value="加入购物车" class="submit_join m_10">
						<div class="msgbox" style="width:350px;display:none">
							<div class="msg_t"><a class="close f_r" onclick="$(this).parents('.msgbox').hide();">关闭</a>请选择规格</div>
							<div class="msg_c" id='product_box_<?php echo isset($id)?$id:"";?>'></div>
						</div>
					</ul>
				</div>
			</div>
		</div>
		<?php }?>
		<div class="main comment_list f_r">
			<div class="tabs">
				<div class="tabs_menu uc_title">
					<label  <?php echo IReq::get('type')==null?'class="current"':"";?>>
						<span><a href="<?php echo IUrl::creatUrl("/site/comments_list/id/$id");?>">全部评论（<?php echo isset($comment_total)?$comment_total:"";?>)条</a></span>
					</label>
					<label  <?php echo IReq::get('type')=='good'?'class="current"':"";?>>
						<span><a href="<?php echo IUrl::creatUrl("/site/comments_list/id/$id/type/good");?>">好评（<?php echo isset($this->data['point_grade']['good'])?$this->data['point_grade']['good']:"";?>条）</a></span>
					</label>
					<label  <?php echo IReq::get('type')=='middle'?'class="current"':"";?>>
						<span><a href="<?php echo IUrl::creatUrl("/site/comments_list/id/$id/type/middle");?>">中评（<?php echo isset($this->data['point_grade']['middle'])?$this->data['point_grade']['middle']:"";?>条）</a></span></label>
					<label  <?php echo IReq::get('type')=='bad'?'class="current"':"";?>>
						<span><a href="<?php echo IUrl::creatUrl("/site/comments_list/id/$id/type/bad");?>">差评（<?php echo isset($this->data['point_grade']['bad'])?$this->data['point_grade']['bad']:"";?>条）</a></span>
					</label>
				</div>

				<div class="tabs_content">

					<?php foreach($this->data['comment_list'] as $key => $item){?>
					<?php $point_width=($item['point']/5)*70?>
					<div class="node item">
						<div class="user">
							<div class="ico"><img src="<?php echo IUrl::creatUrl("")."";?><?php echo isset($item['head_ico'])?$item['head_ico']:"";?>" width="70" height="70" onerror="this.src='<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/images/front/user_ico.gif";?>'" /></div>
							<a class="blue"><?php echo isset($item['username'])?$item['username']:"";?></a>
							<p class="gray">(<?php echo isset($item['user_group_name'])?$item['user_group_name']:"";?>)</p>
							<p class="gray"></p>
						</div>
						<dl class="desc">
							<p class="clearfix"><b>评分：</b><span class="grade"><i style="width:<?php echo isset($point_width)?$point_width:"";?>px"></i></span><span class="light_gray"><?php echo isset($dateline)?$dateline:"";?></span><label></label></p>
							<hr />
							<p><b>评语：</b><span class="gray"><?php echo isset($item['contents'])?$item['contents']:"";?></span></p>
						</dl>
						<div class="corner b"></div>
						<div class="corner tl"></div>
					</div>
					<hr />
					<?php }?>

					<div class="pages_bar">
						<?php echo $this->comment_query->getPageBar();?>
					</div>
				</div>
			</div>
		</div>
	</div>


	<?php echo $siteConfig->site_footer_code;?>
</div>
<script type='text/javascript' src='<?php echo IUrl::creatUrl("")."views/".$this->theme."/javascript/site.js";?>'></script>
<script type='text/javascript'>
	$('input:text[name="word"]').bind({
		keyup:function(){autoComplete('<?php echo IUrl::creatUrl("/site/autoComplete");?>','<?php echo IUrl::creatUrl("/site/search_list/word/@word@");?>','<?php echo isset($site_config['auto_finish'])?$site_config['auto_finish']:"";?>');}
	});

	var mycartLateCall = new lateCall(200,function(){showCart('<?php echo IUrl::creatUrl("/simple/showCart");?>')});

	//购物车div层
	$('.mycart').hover(
		function(){
			mycartLateCall.start();
		},
		function(){
			mycartLateCall.stop();
			$('#div_mycart').hide('slow');
		}
	);

	//[ajax]加入购物车
	function joinCart_ajax(id,type)
	{
		var url ="<?php echo IUrl::creatUrl("/simple/joinCart/random/@random@/goods_id/@goods_id@/type/@type@");?>";
		url = url.replace("@random@",Math.random()).replace("@goods_id@",id).replace("@type@",type);
		$.getJSON(url,function(content){
			if(content.isError == false)
			{
				var count = parseInt($('[name="mycart_count"]').html());
				$('[name="mycart_count"]').html(count + 1);
				$('.msgbox').hide();
				alert(content.message);
			}
			else
			{
				alert(content.message);
			}
		});
	}

	//列表页加入购物车统一接口
	function joinCart_list(id)
	{
		var url = "<?php echo IUrl::creatUrl("/simple/getProducts/id/@id@");?>";
		$.get('<?php echo IUrl::creatUrl("/simple/getProducts");?>',{id:id},function(content){
			if(content == '')
			{
				joinCart_ajax(id,'goods');
			}
			else
			{
				$('#product_box_'+id).html(content);
				$('#product_box_'+id).parent().show();
			}
		});
	}
</script>
</body>
</html>
